package com.glureau.aib.server.equipe;

import java.util.List;

import com.glureau.aib.shared.equipe.PionInfo;
import com.google.gwt.view.client.HasData;
import com.google.gwt.view.client.ListDataProvider;

public class PionDatabase {

	/**
	 * The singleton instance of the database.
	 */
	private static PionDatabase instance;

	/**
	 * The provider that holds the list of contacts in the database.
	 */
	private ListDataProvider<PionInfo> dataProvider = new ListDataProvider<PionInfo>();

	/**
	 * Get the singleton instance of the contact database.
	 * 
	 * @return the singleton instance
	 */
	public static PionDatabase get() {
		if (instance == null) {
			instance = new PionDatabase();
		}
		return instance;
	}

	private PionDatabase() {
		List<PionInfo> pions = dataProvider.getList();
		pions.add(new PionInfo());
	}

	/**
	 * Add a display to the database. The current range of interest of the
	 * display will be populated with data.
	 * 
	 * @param display
	 *            a {@Link HasData}.
	 */
	public void addDataDisplay(HasData<PionInfo> display) {
		dataProvider.addDataDisplay(display);
	}

	/**
	 * Refresh all displays.
	 */
	public void refreshDisplays() {
		dataProvider.refresh();
	}
}
